package com.example.tian.securityinspection.module.library;


import android.app.AlarmManager;
import android.content.Context;
import android.content.res.AssetManager;

import com.example.tian.securityinspection.module.qualifiers.ApplicationContext;
import com.example.tian.securityinspection.module.qualifiers.FilesDirectory;
import com.google.common.base.Preconditions;

import java.io.File;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

@Module(
        library = true
)
public class ContextProvider {

    private final Context mApplicationContext;

    public ContextProvider(Context context) {
        this.mApplicationContext = Preconditions.checkNotNull(context,"context cannot be null");
    }

    @Provides
    @ApplicationContext
    public Context provideApplicationContext(){
        return mApplicationContext;
    }

    @Provides
    @FilesDirectory
    public File providePrivateFileDirectory(){
        return mApplicationContext.getFilesDir();
    }

    @Provides
    @Singleton
    public AssetManager provideAssetManager(){
        return mApplicationContext.getAssets();
    }

    @Provides
    @Singleton
    public AlarmManager provideAlarmManager(){
        return (AlarmManager) mApplicationContext.getSystemService(Context.ALARM_SERVICE);
    }


}
